//
//  MKMapView+Distance.m
//  AiFang
//
//  Created by wadecong on 13-4-12.
//  Copyright (c) 2013年 anjuke. All rights reserved.
//

#import "MKMapView+Distance.h"

@implementation MKMapView (Distance)

- (CLLocationDistance)distanceBetweenCGPointA:(CGPoint)a CGPointB:(CGPoint)b{
    CLLocationCoordinate2D coA = [self convertPoint:a toCoordinateFromView:self];
    CLLocationCoordinate2D coB = [self convertPoint:b toCoordinateFromView:self];
    CLLocation *clA = [[CLLocation alloc] initWithLatitude:coA.latitude longitude:coA.longitude];
    CLLocation *clB = [[CLLocation alloc] initWithLatitude:coB.latitude longitude:coB.longitude];
    CLLocationDistance dis = [clA distanceFromLocation:clB];
    return dis;
}

- (CLLocationDistance)distanceOfCurrentViewFromTopToEnd{
    return [self distanceBetweenCGPointA:CGPointMake(0, 0) CGPointB:CGPointMake(0, self.frame.size.height)];
}

@end
